package edu.sjtu.grid.workflow.facts;

import edu.sjtu.grid.workflow.Util;

public class FixedCost extends Cost{

	//fixed
	private double cost = 0;
	
	public FixedCost(double cost) {
		this.cost = cost;
	}
	
	public double getCost() {
		return cost;
	}
	
	@Override
	public boolean isFixed()
	{
		return true;
	}
	
	@Override
	public String getPayString() {
		return "fixed";
	}
	
	@Override
	public String getCostString() {
		return ""+this.cost;
	}
	
	@Override
	public double getCheapestCost()
	{
		return this.cost;
	}
	
	@Override
	public double getAvgCost() {
		return this.cost;
	}
	
	@Override
	public double getNextCheapestTime(double time)
	{
		return time;
	}
	
	@Override
	public double getRealCost(double fromTime, double toTime) {
		return this.cost * (toTime - fromTime);
	}

	@Override
	public Double getCheapestCost(double from, double to, double duration) {
		if(Util.isEqualOrSmall(from + duration , to))
			return from;
		else
			return null;
	}

	@Override
	public double getInitialCost() {
		return cost;
	}

}
